<?php
/**
 * Created by PhpStorm.
 * User: yekong
 * Date: 2018/5/3
 * Time: 下午1:46
 */
header("Content-type: text/html; charset=utf-8");


$servername = "127.0.0.1";
$username = "root";
$password = "123456";

// 创建连接
$conn = new mysqli($servername, $username, $password,'new_schema');

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
echo "连接成功";

$sql = "SELECT * FROM user";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // 输出数据
    while($row = $result->fetch_assoc()) {
        print_r($row);
    }
} else {
    echo "0 结果";
}